package com.itheima.mm.mapper;

import com.itheima.mm.pojo.Company;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Description CompanyMapper
 * @Author xiao
 * @Date 2024-06-26
 */
@Mapper
public interface CompanyMapper {

    //获取全部公司数据
    @Select("select * from t_company")
    List<Company> selectListAll();


    //更新公司数据
    void update(Company company);

    //启用禁用公司
    @Update("UPDATE t_company SET state = #{state} WHERE id = #{id}")
    int updateCompanyStatus(@Param("id") Integer id, @Param("state") Integer state);
//    分页查询企业列表
    List<Company> selectAllCompanies(@Param("shortName") String shortName, @Param("isDis") Integer isDis);

//新增企业
@Insert("INSERT INTO t_company (short_name, full_name, is_famous, state, remark, create_date, city_id, user_id, order_no) " +
        "VALUES (#{shortName}, #{fullName}, #{isFamous}, #{state}, #{remark}, #{createDate}, #{cityId}, #{userId}, #{orderNo})")
@Options(useGeneratedKeys = true, keyProperty = "id")
void insertCompany(Company company);

//删除企业
@Delete("DELETE FROM t_company WHERE id = #{id}")
void deleteCompanyById(int id);

    Company getById(Integer companyId);
}
